package cn.xianshu.feign.client;

import cn.xianshu.coursedto.CourseDoc;
import cn.xianshu.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Component
@Slf4j
public class CourseESFeignClientFallBackFactory implements FallbackFactory<CourseESFeignClient> {

    @Override
    public CourseESFeignClient create(Throwable throwable) {
        return new CourseESFeignClient(){
            @Override
            public AjaxResult save(CourseDoc doc) {
                log.error("服务降级了", throwable.getMessage());
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("系统繁忙!");
            }

            @Override
            public AjaxResult remove(Long id) {
                log.error("服务降级了", throwable.getMessage());
                throwable.printStackTrace();
                return AjaxResult.me().setSuccess(false).setMessage("系统繁忙!");
            }
        };
    }
}
